this.name = "rmb-override-missile-script";
this.author = "Ramirez";
this.copyright = "January 2009";
this.description = "Prevents a Violet Flax override missile from being effective against stations and other stationary objects.  If player is the target, a random piece of equipment is damaged";
this.version = "2.0";
this.damageSystems = function()
 {
if(!this.ship.target || (this.ship.target.isStation && this.ship.target.maxSpeed == 0) || this.ship.target.scanClass == "CLASS_ROCK") return
if(this.ship.target.isPlayer)
  {
         var list = ["EQ_ADVANCED_COMPASS", "EQ_DOCK_COMP", "EQ_ECM", "EQ_FUEL_INJECTION", "EQ_TARGET_MEMORY",         "EQ_SCANNER_SHOW_MISSILE_TARGET"]
          let equipment = list[Math.floor(Math.random() * list.length)]
          if(player.ship.hasEquipment(equipment))
        {
        player.ship.setEquipmentStatus(equipment, "EQUIPMENT_DAMAGED")
        player.commsMessage("Warning: Missile detonation caused failure of " + EquipmentInfo.infoForKey(equipment).name, 5)
        this.ship.reactToAIMessage("DETONATE");
        }
  }
  else
  {
   if(this.ship.target.AI == "rmb-overrideAI.plist") {
      log("RMB-OVERRIDE-MISSILE-SCRIPT.JS","Target already affected, aborting.");
   } else {
      log("RMB-OVERRIDE-MISSILE-SCRIPT.JS","Overriding target.");
        this.ship.target.setAI("rmb-overrideAI.plist")
   }
  }
}